
#include <QtDBus/QtDBus>
#include <qapplication.h>
#include <qobject.h>

// class MainWindow;
/*
 * Adaptor class for interface com.deepin.dde.Dock
 */

class Adapter : public QObject {
    Q_OBJECT
public:
    qint32 geometry() {
        return 555;
    }
};

class DBusAdaptors: public QDBusAbstractAdaptor
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "com.test.adapter")
    Q_CLASSINFO("D-Bus Introspection", ""
                                       "  <interface name=\"com.test.adapter\">\n"
                                       "    <property access=\"read\" type=\"i\" name=\"geometry\"/>\n"
                                       "    <method name=\"geometry\">\n"
                                       "      <arg direction=\"out\" type=\"i\" name=\"ret\"/>\n"
                                       "    </method>\n"
                                       "  </interface>\n"
                                       "")

    Q_PROPERTY(qint32 geometry READ geometry NOTIFY geometryChanged)
public:
    DBusAdaptors(Adapter *parent = nullptr) : QDBusAbstractAdaptor(parent) {};
    ~DBusAdaptors() {};

    Adapter *parent() const {
        return static_cast<Adapter*>(QObject::parent());
    };

public slots: // PROPERTIES
    qint32 geometry() const { 
        qDebug() << "geometry";
        return parent()->geometry(); 
    };

signals:
    void geometryChanged(QRect geometry);
};
